package filedemo2;

public class Main9 {
    public static void main(String[] args) {
        java.io.File file = new java.io.File("C://Users//Administrator//Desktop");
        getAllDirectory(file);
    }


    public static void getAllDirectory(java.io.File file) {
        //创建过滤器
        java.io.File[] f = file.listFiles(new GetAllDirectory());
        for (java.io.File f1 : f) {
            System.out.println(f1);
            //判断目录是否为空
            if (f1.length() != 0)
                getAllDirectory(f1);
        }
    }

}

class GetAllDirectory implements java.io.FileFilter {

    @Override
    public boolean accept(java.io.File pathname) {
        // 去除所有非文件夹
        return pathname.isDirectory();
    }
}
